package tech.ezrealc.fall2023.repository;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.ezrealc.fall2023.model.session.SessionDO;

import java.math.BigInteger;
import java.util.Map;

public interface SessionRepository {

    @Select("select * from system_session where user = #{id}")
    SessionDO findById(@Param("id") BigInteger id);

    @Select("insert into system_session value (#{user}, #{token})")
    void insertSession(SessionDO sessionDO);

    @Delete("delete from system_session where token = #{token}")
    int deleteSessionByToken(@Param("token") String token);

    @Select("select count(*) as count from fall2023.system_session where token = #{token}")
    Map<String, Long> hasRecord(@Param("token")String token);

}
